from selenium.webdriver.common.by import By
from util_tools.basePage import BasePage
import allure

class LoginPage(BasePage):
    url = '/user.php'
    username = (By.NAME, 'username')
    password = (By.NAME, 'password')
    submit = (By.NAME, 'submit')
    assert_result = (By.XPATH, '//*[@id="ECS_MEMBERZONE"]/font/font')

    def login(self, user_name, pass_word):
        self.open_url(self.url)
        allure.attach(self.url, '打开登录测试页面', attachment_type=allure.attachment_type.TEXT)
        self.send_keys(self.username, user_name)
        self.send_keys(self.password, pass_word)
        self.click(self.submit)
        allure.attach(self.screenshots_png(), f'输入账户:{user_name}, 密码:{pass_word}, 内容截屏', attachment_type=allure.attachment_type.PNG)